
u9ImHd.registerModule('Demo', [])

    .config(['$stateProvider', '$ocLazyLoadProvider', function ($stateProvider, $ocLazyLoadProvider) {
        $stateProvider
            .state('Demo', {
                url: '/Demo',
                templateUrl: u9ImHd.getFullPath('tpls/home.html', 'Demo'),
                resolve: {
                    loadFile: ['$q', '$ocLazyLoad', function($q, $ocLazyLoad) {
                        var defer = $q.defer();
                        
                        $ocLazyLoad.load(['angular-cookies', 'DemoFile']).then(function () {
                            angular.module('Demo').requires.push('ngCookies');
                            defer.resolve();
                        }, function () {
                            defer.reject();
                        });

                        return defer.promise;
                    }]
                }
            })
            .state('Demo-serial', {
                url: '/Demo-serial',
                templateUrl: u9ImHd.getFullPath('tpls/serial.html', 'Demo'),
                controller: 'Demo.SerialCtrl'
            })
            .state('Demo-grid', {
                url: '/Demo-grid',
                templateUrl: u9ImHd.getFullPath('tpls/grid.html', 'Demo'),
                controller: 'Demo.GridCtrl'
            })
            .state('Demo-detail', {
                url: '/Demo-detail',
                templateUrl: u9ImHd.getFullPath('tpls/detail.html', 'Demo'),
                controller: 'Demo.DetailCtrl'
            });

        $ocLazyLoadProvider.config({
            modules: [{
                name: 'angular-cookies',
                files: [
                    u9ImHd.getFullPath('lib/angular-cookies/angular-cookies.js', 'Demo')
                ]
            }, {
                name: 'DemoFile',
                files: [
                    u9ImHd.getFullPath('js/controllers/Demo.SerialCtrl.js', 'Demo'),
                    u9ImHd.getFullPath('js/controllers/Demo.GridCtrl.js', 'Demo'),
                    u9ImHd.getFullPath('js/controllers/Demo.DetailCtrl.js', 'Demo')
                ]
            }]
        });
    }]);
